<?php
function get_goods($map,$limit,$order){
	$goods = D('Goods');

	if (is_array($map)) {
		$where = $map;
	}else{
		$map = get_category_child($map);
		$where['category_id'] = array('IN',$map);
	}
	$where['surplus'] = array('gt',0);
	$list = $goods->where($where)->order($order)->limit($limit)->select();
	return $list;
}

function get_brand_list($category){
    $list = S('sys_brand_list');
    /* 读取缓存数据 */
    if(empty($list)){
        $list = D('GoodsBrand')->select();
        S('sys_brand_list',$list);
    }
    $categorys = get_category_child($category);
    foreach ($list as $key => $value) {
        if (in_array($value['category_id'], $categorys)) {
            $res[] = $value;
        }
    }
    return $res;
}